package com.wizinno.android.urineflow.serialport;

/**
 * @author LiuMei
 * @date 2020-11-24.
 */
public interface SerialProtocol {

    byte DEVICE_A1 = (byte) 0xA1;
    byte DEVICE_A2 = (byte) 0xA2;
    byte EVENT = (byte) 0x40;

    byte VERSION = (byte) 0xF0;

    byte[] A1_VERSION = {DEVICE_A1,VERSION};
    byte[] A2_VERSION = {DEVICE_A2,VERSION};

    byte[] COLLECT_START = {DEVICE_A1, 0x31, 0x01, 0x00, 0x00, 0x00, 0x52, 0x65};
    byte[] COLLECT_END = {DEVICE_A1, 0x31, 0x00, 0x00, 0x00, 0x00, (byte) 0xAE, 0x64};

    /**
     * 人靠近、离开
     */
    byte NEAR = 0x01;
    String NEAR_DESC = "人靠近";
    byte LEAVE = 0x02;
    String LEAVE_DESC = "人离开";
    byte[] PEOPLE_NEAR = {DEVICE_A1, EVENT, NEAR};
    byte[] PEOPLE_LEAVE = {DEVICE_A1, EVENT, LEAVE};

    /**
     * 按钮ON、OFF
     */
    byte ON = 0x03;
    String ON_DESC = "按钮ON";
    byte OFF = 0x04;
    String OFF_DESC = "按钮OFF";
    byte[] BUTTON_ON = {DEVICE_A1, EVENT, ON};
    byte[] BUTTON_OFF = {DEVICE_A1, EVENT, OFF};

    /**
     * 读取重量、ADC
     */
    byte[] READ_WEIGHT = {DEVICE_A2, (byte) 0x80};
    byte[] READ_ADC = {DEVICE_A2, (byte) 0x82};
    /**
     * 零点、500g校准值
     */
    byte[] READ_CHECK_0 = {DEVICE_A2, (byte) 0x90};
    byte[] READ_CHECK_500 = {DEVICE_A2, (byte) 0x92};
    byte[] WRITE_CHECK_0_PREFIX = {DEVICE_A2, (byte) 0x91};
    byte[] WRITE_CHECK_500_PREFIX = {DEVICE_A2, (byte) 0x93};

    /**
     * 阀门状态读写
     */
    byte VALVE_STATUS_OPEN = 0x01;
    byte VALVE_STATUS_CLOSE = 0x02;
    byte[] VALVE_STATUS_READ_PREFIX = {DEVICE_A1, 0x14};
    byte[] VALVE_STATUS_WRITE_PREFIX = {DEVICE_A1, 0x15};

    /**
     * 距离设置
     */
    //按钮ON/OFF事件检测距离设定值
    byte[] DISTANCE_BUTTON =  {DEVICE_A1,0x22};
    byte[] DISTANCE_BUTTON_WRITE_PREFIX =  {DEVICE_A1,0x23};
    //人靠近/离开事件检测距离设定值
    byte[] DISTANCE_PEOPLE = {DEVICE_A1,0x24};
    byte[] DISTANCE_PEOPLE_WRITE_PREFIX = {DEVICE_A1,0x25};
    //按钮ON/OFF事件检测抖动时间设定值
    byte[] DISTANCE_BUTTON_TIME =  {DEVICE_A1,0x26};
    byte[] DISTANCE_BUTTON_TIME_WRITE_PREFIX =  {DEVICE_A1,0x27};
    //人靠近/离开事件检测抖动时间设定值
    byte[] DISTANCE_PEOPLE_TIME = {DEVICE_A1,0x28};
    byte[] DISTANCE_PEOPLE_TIME_WRITE_PREFIX = {DEVICE_A1,0x29};

    //读取测距值
    byte[] READ_DISTANCE = {DEVICE_A1,0x20};

    /**
     * 舵机
     */
    byte[] READ_STEERING_STATUS = {DEVICE_A2,0x00};
    byte[] READ_STEERING_ANGLE = {DEVICE_A2,0x02};

    byte[] TURN0 = {(byte) 0xA2, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00};
    byte[] TURN90 = {(byte) 0xA2, 0x01, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00};
    byte[] WASH = {(byte) 0xA2, 0x01, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00};
}
